package ferran.alcazar.one;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;

public class principal extends Activity {
	EditText et1, et2, et3;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		setContentView(R.layout.principal);

		et1 = (EditText) findViewById(R.id.editText1);
		et2 = (EditText) findViewById(R.id.editText2);
		et3 = (EditText) findViewById(R.id.editText3);
	}

	public void alta(View V) {

		//dbHelper admin = new dbHelper(this, null, 1); // instanciamos la clase
														// de la bd
		//SQLiteDatabase bd = admin.getWritableDatabase(); // metodo para escribir
															// en la bd

		String nombre = et1.getText().toString();
		String edad = et2.getText().toString();
		String pais = et3.getText().toString();

		//ContentValues cv = new ContentValues();

		//cv.put("nombre", nombre);
		//cv.put("edad", edad);
		//cv.put("pais", pais);

		//bd.insert("Usuarios", null, cv);
		//bd.close();

		et1.setText("");
		et2.setText("");
		et3.setText("");
		
		Toast.makeText(this, "Usuario registrado correctamente",
				Toast.LENGTH_SHORT).show();
		
		Intent intent = new Intent(principal.this, And_pipatijActivity.class);
		
		Bundle b = new Bundle();
		b.putString("nombre", nombre);
		b.putString("edad", edad);
		b.putString("pais", pais);
		
		intent.putExtras(b);

		principal.this.startActivity(intent);
		
		
	}



	public void language() {
		Intent intent = new Intent(principal.this, idiomas.class);
		principal.this.startActivity(intent);
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		MenuInflater inflater = getMenuInflater();
		inflater.inflate(R.menu.menu, menu);
		return true;
	}

	// option menu
	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		// Handle item selection
		switch (item.getItemId()) {
		case R.id.new_game:
			//empezar();
			return true;
		case R.id.language:
			language();
			return true;
		case R.id.location:
			location();
			return true;
		case R.id.log:
			log();
			return true;
		default:
			return super.onOptionsItemSelected(item);
		}
	}

	private void location() {
		Intent intent = new Intent(principal.this, MapaActivity.class);
		principal.this.startActivity(intent);
	}
	
	private void log() {
		Intent intent = new Intent(principal.this, log.class);
		principal.this.startActivity(intent);
	}
}